#ifdef USE_HEURISTIC_SELECTION_LIBRARY

#include "moveHeuristicSelection.h"
#include <cstdlib>   // for rand

MoveSelector::MoveSelector(int** grid, bool** fixed, int grLen, int sqLen)
: grid_(grid),
  fixed_(fixed),
  grLen_(grLen),
  sqLen_(sqLen)
  { }

Singleton<RCRC> MoveSelector::select()
{
	//pick first cell to swap
    int r1, c1, r2, c2;
	do{
		r1=rand()%grLen_;
		c1=rand()%grLen_;
	}while(fixed_[r1][c1]);
	//pick second cell to swap (must be not fixed AND must be in the same
	//square as the first cell
	do{
		r2=(rand()%sqLen_)+((r1/sqLen_)*sqLen_);
		c2=(rand()%sqLen_)+((c1/sqLen_)*sqLen_);
	}while(fixed_[r2][c2] || (r1==r2 && c1==c2) );
        
    RCRC r(r1, c1, r2, c2); 
    return r;
}

    
#endif
